package org.jackysoft.entity;

import java.util.Calendar;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.jackysoft.entity.User;
import org.jackysoft.util.MySqlSchema;
import org.joda.time.DateTime;

@Entity
@org.hibernate.annotations.Entity(
		dynamicInsert=true,
		dynamicUpdate=true
)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Table(schema=MySqlSchema.Businessbase)
public class ReceivedFileItem extends FileItem {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8873043744505431885L;
	private User fromer;
    private String ip;
    private boolean enabled = false;
    private User passor;
    private Calendar passedDate;
    private String  folder;
    
    
    
    
    public ReceivedFileItem(String id,User fromer,String title,User  owner,DateTime ctime,String fileType) {
    	super();
    	this.id = id;
    	this.fromer = fromer;
    	this.title = title;
    	this.owner = owner;
    	this.createTime = ctime;
    	this.fileType = fileType;
    	
    }
	public ReceivedFileItem(String id,User fromer,String title,User  owner,DateTime ctime,String fileType,User passor,Calendar passedDate) {
		this(id,fromer,title,owner,ctime,fileType);
		this.passor = passor;
		this.passedDate = passedDate;
	}

	public ReceivedFileItem(String realName) {
		super(realName);
		
	}

	public ReceivedFileItem() {
		super();
		
	}

	public ReceivedFileItem(UploadedFileItem uf) {
	    this.setFromer(uf.getOwner());
	    this.setRealName(uf.getRealName());
	    this.setSize(uf.getSize());
	    this.setTitle(uf.getTitle());	
	    this.setImgpath(uf.getImgpath());
	}
     
	public ReceivedFileItem(ReceivedFileItem uf) {
	    this.setFromer(uf.getOwner());
	    this.setRealName(uf.getRealName());
	    this.setSize(uf.getSize());
	    this.setTitle(uf.getTitle());	
	    this.setImgpath(uf.getImgpath());
	}

	/**
	 * @return the fromer
	 */
	@ManyToOne
	@JoinColumn(name="fromer_name")
	public User getFromer() {
		return fromer;
	}

	/**
	 * @param fromer the fromer to set
	 */
	public void setFromer(User fromer) {
		this.fromer = fromer;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public boolean isEnabled() {
		return enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	
	/**
	 * 用户文件权限审核通过
	 * */
	@ManyToOne
	public User getPassor() {
		return passor;
	}

	public void setPassor(User passor) {
		this.passor = passor;
	}

	public Calendar getPassedDate() {
		return passedDate;
	}

	public void setPassedDate(Calendar passedDate) {
		this.passedDate = passedDate;
	}
	
	@Column(columnDefinition="varchar(100) default 'myroot'")
	public String getFolder() {
		return folder;
	}
	public void setFolder(String folder) {
		this.folder = folder;
	}

	
	
}
